{
int i;
- printk ("ACT: Initialising Accurate timers\n");
-
open_softirq(AC_TIMER_SOFTIRQ, ac_timer_softirq_action);
for ( i = 0; i < smp_num_cpus; i++ )
#define KEY_MAX 256
#define STR_MAX 64
-typedef struct _key_te {
+static struct {
key_handler *handler;
char desc[STR_MAX];
-} key_te_t;
+} key_table[KEY_MAX];
-static key_te_t key_table[KEY_MAX];
-
-void add_key_handler(u_char key, key_handler *handler, char *desc)
+void add_key_handler(unsigned char key, key_handler *handler, char *desc)
{
- int i;
- char *str;
-
- if ( key_table[key].handler != NULL )
- printk("Warning: overwriting handler for key 0x%x\n", key);
-
key_table[key].handler = handler;
-
- str = key_table[key].desc;
- for ( i = 0; i < STR_MAX; i++ )
- {
- if ( *desc != '\0' )
- *str++ = *desc++;
- else
- break;
- }
- if ( i == STR_MAX )
- key_table[key].desc[STR_MAX-1] = '\0';
+ strncpy(key_table[key].desc, desc, STR_MAX);
+ key_table[key].desc[STR_MAX-1] = '\0';
}
-key_handler *get_key_handler(u_char key)
+key_handler *get_key_handler(unsigned char key)
{
return key_table[key].handler;
}
-static void show_handlers(u_char key, void *dev_id, struct pt_regs *regs)
+static void show_handlers(unsigned char key, void *dev_id,
+ struct pt_regs *regs)
{
int i;
-
- printk("'%c' pressed -> showing installed handlers\n", key);
+ printk("'%c' pressed -> showing installed handlers\n", key);
for ( i = 0; i < KEY_MAX; i++ )
if ( key_table[i].handler != NULL )
printk(" key '%c' (ascii '%02x') => %s\n",
}
-static void dump_registers(u_char key, void *dev_id, struct pt_regs *regs)
+static void dump_registers(unsigned char key, void *dev_id,
+ struct pt_regs *regs)
{
extern void show_registers(struct pt_regs *regs);
printk("'%c' pressed -> dumping registers\n", key);
show_registers(regs);
}
-static void halt_machine(u_char key, void *dev_id, struct pt_regs *regs)
+static void halt_machine(unsigned char key, void *dev_id,
+ struct pt_regs *regs)
{
printk("'%c' pressed -> rebooting machine\n", key);
machine_restart(NULL);
}
-void do_task_queues(u_char key, void *dev_id, struct pt_regs *regs)
+void do_task_queues(unsigned char key, void *dev_id,
+ struct pt_regs *regs)
{
unsigned long flags;
- struct domain *d;
- shared_info_t *s;
+ struct domain *d;
s_time_t now = NOW();
printk("'%c' pressed -> dumping task queues (now=0x%X:%08X)\n", key,
d->domain, d->processor,
test_bit(DF_RUNNING, &d->flags) ? 'T':'F',
atomic_read(&d->refcnt), d->tot_pages);
- s = d->shared_info;
printk("Guest: upcall_pend = %02x, upcall_mask = %02x\n",
- s->vcpu_data[0].evtchn_upcall_pending,
- s->vcpu_data[0].evtchn_upcall_mask);
+ d->shared_info->vcpu_data[0].evtchn_upcall_pending,
+ d->shared_info->vcpu_data[0].evtchn_upcall_mask);
printk("Notifying guest...\n");
send_guest_virq(d, VIRQ_DEBUG);
}
read_unlock_irqrestore(&tasklist_lock, flags);
}
-extern void dump_runq(u_char key, void *dev_id, struct pt_regs *regs);
-extern void print_sched_histo(u_char key, void *dev_id, struct pt_regs *regs);
-extern void reset_sched_histo(u_char key, void *dev_id, struct pt_regs *regs);
+extern void dump_runq(unsigned char key, void *dev_id,
+ struct pt_regs *regs);
+extern void print_sched_histo(unsigned char key, void *dev_id,
+ struct pt_regs *regs);
+extern void reset_sched_histo(unsigned char key, void *dev_id,
+ struct pt_regs *regs);
#ifdef PERF_COUNTERS
-extern void perfc_printall (u_char key, void *dev_id, struct pt_regs *regs);
-extern void perfc_reset (u_char key, void *dev_id, struct pt_regs *regs);
+extern void perfc_printall(unsigned char key, void *dev_id,
+ struct pt_regs *regs);
+extern void perfc_reset(unsigned char key, void *dev_id,
+ struct pt_regs *regs);
#endif
-#ifndef NDEBUG
-void reaudit_pages(u_char key, void *dev_id, struct pt_regs *regs);
-void audit_all_pages(u_char key, void *dev_id, struct pt_regs *regs);
-#endif
-
void initialize_keytable(void)
{
- int i;
-
- /* first initialize key handler table */
- for ( i = 0; i < KEY_MAX; i++ )
- key_table[i].handler = (key_handler *)NULL;
-
- /* setup own handlers */
add_key_handler('d', dump_registers, "dump registers");
add_key_handler('h', show_handlers, "show this message");
add_key_handler('l', print_sched_histo, "print sched latency histogram");
add_key_handler('p', perfc_printall, "print performance counters");
add_key_handler('P', perfc_reset, "reset performance counters");
#endif
-#ifndef NDEBUG
- add_key_handler('m', reaudit_pages, "re-audit pages");
- add_key_handler('M', audit_all_pages, "audit all pages");
-#endif
}
return rc;
}
-
-
-#ifndef NDEBUG
-/*
- * below are various memory debugging functions:
- * __audit_page(): prints out all the ptes a pages is listed in
- * audit_page(): in addition maintains a history of audited pages
- * reaudit_pages(): re-audit previously audited pages
- * audit_all_pages(): check the ref-count for all leaf pages
- * reaudit_page() and audit_all_pages() are designed to be
- * keyhandler functions so that they can be easily invoked from the console.
- */
-
-
-/*
- * prints out all the pt's a page is listed in
- */
-void __audit_page(unsigned long pfn) {
- unsigned long i, j;
- struct pfn_info *page;
- unsigned long page_addr;
- l1_pgentry_t *pl1e, l1e;
-
- page = &frame_table[pfn];
- page_addr = pfn << PAGE_SHIFT;
-
- printk("audit page: pfn=%lx info: cf=%x tf=%x ts=%x dom=%lx\n", pfn,
- page->count_and_flags, page->type_and_flags,
- page->tlbflush_timestamp, (unsigned long)page->u.domain);
-
- /* walk the frame table */
- for ( i = 0; i < max_page; i++ )
- {
- if ( (frame_table[i].count_and_flags & PGC_count_mask) == 0 )
- continue;
-
- /* check if entry is a page table (L1 page table) and in use */
- if ( ((frame_table[i].type_and_flags & PGT_type_mask) ==
- PGT_l1_page_table) &&
- ((frame_table[i].type_and_flags & PGT_count_mask) != 0) )
- {
- pl1e = map_domain_mem(i << PAGE_SHIFT);
-
- /* scan page table for page to audit */
- for ( j=0; j < ENTRIES_PER_L1_PAGETABLE; j++ )
- {
- l1e = pl1e[j];
- if ( l1_pgentry_empty(l1e) )
- continue;
- if ( l1_pgentry_to_pagenr(l1e) == pfn )
- {
- printk(" pte_pfn=%06lx cf=%08x tf=%08x dom=%08lx\n",
- i, frame_table[i].count_and_flags,
- frame_table[i].type_and_flags,
- (unsigned long)frame_table[i].u.domain);
- printk(" pte_idx=%03lx *pte_idx=%08lx\n",
- j, l1_pgentry_val(l1e));
- }
- }
- unmap_domain_mem(pl1e);
- }
- }
-
-}
-
-/*
- * audit a page and keep a history of audited pfns
- */
-#define LASTPAGES_SIZE 128
-static long last_pages[LASTPAGES_SIZE];
-static int last_pages_idx = 0;
-void audit_page(unsigned long pfn)
-{
- unsigned long i;
-
- __cli();
- __audit_page(pfn);
- __sti();
- /* add pfn to last_pages cache if is not already present */
- for ( i = 0; i < LASTPAGES_SIZE; i++ )
- if ( last_pages[i] == pfn )
- return;
-
- /* new entry */
- last_pages[last_pages_idx++] = pfn;
- if ( last_pages_idx >= LASTPAGES_SIZE )
- last_pages_idx = 0;
-
-}
-
-/*
- * re-audit previously audited pages
- */
-void reaudit_pages(u_char key, void *dev_id, struct pt_regs *regs)
-{
- int i;
-
- printk("Dumping audited pages\n");
-
- for ( i = 0; i < LASTPAGES_SIZE; i++ )
- if ( last_pages[i] != 0 )
- __audit_page(last_pages[i]);
-}
-
-/*
- * do various checks on all pages.
- * Currently:
- * - check for pages with corrupt ref-count
- * Interrupts are diabled completely. use with care.
- */
-void audit_all_pages(u_char key, void *dev_id, struct pt_regs *regs)
-{
- unsigned long i, j, k;
- unsigned long ref_count;
- l1_pgentry_t *pl1e, l1e;
-
- printk("audit_all_pages\n");
-
- __cli();
-
- /* walk the frame table */
- for ( i = 0; i < max_page; i++ )
- {
- /* check ref count for leaf pages */
- if ( ((frame_table[i].type_and_flags & PGT_type_mask) ==
- PGT_writeable_page) )
- {
- ref_count = 0;
-
- /* find page tables */
- for ( j = 0; j < max_page; j++ )
- {
- if ( ((frame_table[j].type_and_flags & PGT_type_mask) ==
- PGT_l1_page_table) &&
- ((frame_table[j].type_and_flags & PGT_count_mask) != 0) )
- {
- pl1e = map_domain_mem(j << PAGE_SHIFT);
-
- /* scan page table for page to audit */
- for ( k=0; k < ENTRIES_PER_L1_PAGETABLE; k++ )
- {
- l1e = pl1e[k];
- if ( l1_pgentry_empty(l1e) )
- continue;
- if ( l1_pgentry_to_pagenr(l1e) == i )
- {
- ref_count++;
- /* page is in pagetable */
- }
- }
- unmap_domain_mem(pl1e);
- }
-
- }
-
- /* check for PGC_ALLOCATED */
- if ( (frame_table[i].count_and_flags & PGC_allocated) != 0 )
- ref_count++;
-
- if ( (frame_table[i].count_and_flags & PGC_count_mask)
- != ref_count )
- {
- printk("refcount error: pfn=%06lx cf=%08x refcount=%lx\n",
- i, frame_table[i].count_and_flags, ref_count);
- __audit_page(i);
- printk("\n");
- }
- } /* ref count error */
- }
- __sti();
-
-}
-
-#endif /* NDEBUG */
#define VERBOSE_INFO(_f, _a...) ((void)0)
#endif
-#if 1 || !defined(NDEBUG)
+#ifndef NDEBUG
#define INFO(_f, _a...) printk( _f, ## _a )
#else
#define INFO(_f, _a...) ((void)0)
/* We could set *val to some value but the guest may well be in trouble
* anyway if this write fails. Hopefully the printk will give us a
* clue what went wrong. */
- printk("Guest %u attempting sub-dword %s to BASE_ADDRESS %d\n",
- pdev->owner->domain, (acc == ACC_READ) ? "read" : "write", idx);
+ INFO("Guest %u attempting sub-dword %s to BASE_ADDRESS %d\n",
+ pdev->owner->domain, (acc == ACC_READ) ? "read" : "write", idx);
return -EPERM;
}
pci_for_each_dev(dev)
{
- if ( !pcidev_dom0_hidden(dev) )
+ if ( pcidev_dom0_hidden(dev) )
{
- /* Skip bridges and other peculiarities for now. */
- if ( dev->hdr_type != PCI_HEADER_TYPE_NORMAL )
- continue;
- pdev = kmalloc(sizeof(phys_dev_t), GFP_KERNEL);
- pdev->dev = dev;
- pdev->flags = ACC_WRITE;
- pdev->state = 0;
- pdev->owner = p;
- list_add(&pdev->node, &p->pcidev_list);
- }
- else
- {
printk("Hiding PCI device %s from DOM0\n", dev->slot_name);
+ continue;
}
+
+ /* Skip bridges and other peculiarities for now. */
+ if ( dev->hdr_type != PCI_HEADER_TYPE_NORMAL )
+ continue;
+ pdev = kmalloc(sizeof(phys_dev_t), GFP_KERNEL);
+ pdev->dev = dev;
+ pdev->flags = ACC_WRITE;
+ pdev->state = 0;
+ pdev->owner = p;
+ list_add(&pdev->node, &p->pcidev_list);
}
set_bit(DF_PHYSDEV, &p->flags);